<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj = {
            name: '张三',
            age: 16,
            info: {
                id: 123,
                tel: 110,
                sex: '男'
            }
        }

        function deepCopy(params) {
            var newObj = {}
            if(params instanceof Object) {
                for(let key in params) {
                    // console.log(params[key]);
                    if(params[key] instanceof Object) {
                        newObj[key] = deepCopy(params[key])
                    } else {
                        newObj[key] = params[key]
                    }
                    
                }
            }
            return newObj
        }

        var newObj = deepCopy(obj)
        
        newObj.info.id = 234
        console.log(obj);
    </script>
</body>
</html>